<template>
  <LayoutContainer>
    <div>
      <h2>{{ $t('educationTiming') }}</h2>
      <UiFormEdition
        :model="EducationTiming"
        :go-back-route="goBackRoute"
      >
        <template v-slot="{ entity }">
          <UiInputNumber
            field="educationTiming"
            v-model="entity.timing"
            :rules="rules()"
          />
        </template>
      </UiFormEdition>
    </div>
  </LayoutContainer>
</template>
<script setup lang="ts">
import EducationTiming from '~/models/Education/EducationTiming'
import {RouteLocationPathRaw} from 'vue-router'
import { useI18n } from 'vue-i18n'

const i18n = useI18n()

const goBackRoute: RouteLocationPathRaw = { path: `/parameters`, query: { tab: 'educationTimings' } }

const rules = () => [
  (timing: string | null) =>
    (timing !== null && parseInt(timing) > 0) || i18n.t('please_enter_a_value'),
]
</script>
